import { HttpSrv } from 'lfun-bg-comp';

export interface Grades {
  school_id: string;
  grade_no: string;
  grade_name: string;
  grade_alias: string;
  description: string;
}

export interface SearchGrades {
  borough?: string;
  block?: string;
  school_id?: any;
  grade_id?: any;
  class_name?: string;
  grade_name?: string;
}

// 删除
export const deleteGrades = grade_id => HttpSrv().delete(`/school/v1/grades/`, { params: { grade_id } });
// 查询单个
export const getGrades = grade_id => HttpSrv().get(`/school/v1/grades/`, { params: { grade_id } });
// 新增
export const createGrades = (grades: Grades) => HttpSrv().post(`/school/v1/grades/`, grades);
// 分页 /api/school/v1/grades/page
export const searchGrades = (params: SearchGrades, page: number, per_page: number) =>
  HttpSrv().get('/school/v1/grades/page', { params: { ...params, page, per_page } });
// 修改
export const updateGrades = (grades: Grades) => HttpSrv().put('/school/v1/grades/', grades);
// 获取年级列表
export const listGrades = school_id =>
  HttpSrv().get(`/school/v1/grades/page`, { params: { school_id, page: 1, per_page: 3000 } });

export const listGradeType = () =>
  HttpSrv().get(`/school/v1/enums/page`, { params: { enum_name: 'grade', page: 1, per_page: 3000 } });
